<template>
  <view class="couponPopup">
    <u-popup :show="childShow" :round="10" mode="bottom">
      <view class="title">
        促销
        <!-- 关闭标签 -->
        <text class="font_family icon-guanbi_tongyong_1" @click="closeFn" />
      </view>
      <view class="content">
        <view v-if="newCouponInfo && newCouponInfo.skuActivityInfo.activityType == 10" class="activiy">
          <!-- 特价标签 -->
          <view class="t-icon t-icon-tejia_tongyong_1" />
          <view class="con-right">
            <view class="tips">{{ newCouponInfo.couponTips }}</view>
            <view class="time">{{ newCouponInfo.skuActivityInfo.activityStartTime }} - {{ newCouponInfo.skuActivityInfo.activityEndTime }}</view>
          </view>
        </view>
        <view v-if="newCouponInfo.skuActivityInfo.activityType == 20" class="activiy">
          <!-- 满减 标签 -->
          <view class="t-icon t-icon-manjian_tongyong_1" />
          <view class="con-right">
            <view class="tips">{{ mjhtml }}</view>
            <view class="time">{{ newCouponInfo.skuActivityInfo.activityStartTime }}-{{ newCouponInfo.skuActivityInfo.activityEndTime }}</view>
          </view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>

export default {
  components: {

  },
  props: {
    showPromtion: {
      type: Boolean,
      default: false
    },
    couponInfo: {
      type: Object,
      default: null
    },
  },
  data() {
    return {
      childShow: false,
      newCouponInfo: {},
      mjhtml: '', //满减的时候# 换成单位
    }
  },
  watch: {
    showPromtion(newVal, oldVal) {
      if (newVal != oldVal) {
        this.childShow = newVal
      }
    },
    couponInfo(newVal, oldVal) {
      if (newVal != oldVal) {
        this.newCouponInfo = newVal
        // #ifdef MP-WEIXIN
        this.mjhtml = this.newCouponInfo.couponTips ? this.newCouponInfo.couponTips.replaceAll('#', this.newCouponInfo.unitName ? this.newCouponInfo.unitName : '') : ''
        console.log('促销数据', this.mjhtml)
      // #endif
      // #ifdef MP-ALIPAY
       this.mjhtml = this.newCouponInfo.couponTips ? this.newCouponInfo.couponTips.split('#').join(this.newCouponInfo.unitName):''
      // #endif
      }
    }
  },
  mounted() {
    this.newCouponInfo = this.couponInfo

    console.log('促销')
  },
  methods: {
    reload() {
      this.$emit('getCoupons')
    },
    closeFn() {
      this.$emit('update:showPromtion', false)
    }
  }
}

</script>

<style scoped lang="scss">
.couponPopup {
  color:$uni-text-color;
  font-size: $uni-font-size-base;
  .title {
    height: 88rpx;
    padding: 0rpx 32rpx;
    line-height: 88rpx;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    border-bottom: 2rpx solid $uni-border-gray;
    .font_family {
      font-size: 48rpx;
      font-weight: normal;
    }
  }
  .content {
    padding:0 32rpx 80rpx;
    .activiy {
      display: flex;
      margin:26rpx 0 0;
      padding-bottom:6rpx;
      .t-icon{
        width: 64rpx;
        height: 32rpx;
        margin: 5rpx 16rpx 0 0;
      }
      .con-right{
        width: 604rpx;
      }
      .tips {
        word-break: break-all;
      }
      .time {
        color:$uni-text-color-tips;
        font-size:$uni-font-size-sm;
        margin-top: 8rpx;
      }
    }
  }
}
</style>
